package com.example.learning3;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class self extends AppCompatActivity {
    Button button_function;
    Button button_analysis;
    Button button_setting;
    Button button_nod_head;
    Button button_shake_head;
    Button button_air_cold;
    Button button_air_hot;
    int flag_nod=0;
    int flag_shake=0;
    int air_status=0;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_self);
        seton();
    }
    public void seton(){
        button_function=findViewById(R.id.button_function);
        button_analysis=findViewById(R.id.button_analysis);
        button_setting=findViewById(R.id.button_setting);
        button_nod_head=findViewById(R.id.button_nod_head);
        button_shake_head=findViewById(R.id.button_shake_head);
        button_air_cold=findViewById(R.id.button_air_make_cold);
        button_air_hot=findViewById(R.id.button_air_make_hot);
        button_air_cold.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(air_status==0){
                    air_status=1;
                    button_air_cold.setActivated(true);
                }else if(air_status==1){
                    button_air_cold.setActivated(false);
                    air_status=0;
                }else {
                    button_air_cold.setActivated(true);
                    button_air_hot.setActivated(false);
                    air_status=1;
                }
            }
        });
        button_air_hot.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (air_status==0){
                    air_status=2;
                    button_air_hot.setActivated(true);
                }else if(air_status==2) {
                    button_air_hot.setActivated(false);
                    air_status=0;
                }else {
                    button_air_cold.setActivated(false);
                    button_air_hot.setActivated(true);
                    air_status=2;
                }
            }
        });
        button_function.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent();
                intent.setClass(self.this,MainActivity.class);
                startActivity(intent);
                self.this.finish();
            }
        });
        button_analysis.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent();
                intent.setClass(self.this,MainActivity3.class);
                startActivity(intent);
                self.this.finish();
            }
        });
        button_setting.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent();
                intent.setClass(self.this,setting.class);
                startActivity(intent);
                self.this.finish();
            }
        });
        button_nod_head.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                switch (flag_nod){
                    case 0:
                        button_nod_head.setActivated(true);
                        flag_nod=1;
                        break;
                    case 1:
                        button_nod_head.setActivated(false);
                        flag_nod=0;
                        break;
                }
            }
        });
        button_shake_head.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                switch (flag_shake){
                    case 0:
                        button_shake_head.setActivated(true);
                        flag_shake=1;
                        break;
                    case 1:
                        button_shake_head.setActivated(false);
                        flag_shake=0;
                        break;
                }
            }
        });
    }

}